//  MembershipDetailsViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/8.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
#import "RDVTabBarController.h"
#import "TheLoginViewController.h"
#import "ACETelPrompt.h"
#import "MembershipDetailsViewController.h"
#import "MemberCardTopUpViewController.h"
#import "TradesViewController.h"
#import "MCouponBViewController.h"
#import "MemberInformationViewController.h"
#import "MemberExchangeGiftViewController.h"
#import "ConversationViewController.h"
#import "UIImageView+WebCache.h"
#import "TagView.h"
#import "ReabamSingleton.h"
#import "TheEditingViewController.h"
#import "SelectTag_NewViewController.h"
#import "MemberInformationCell.h"
#import "CashierNewViewController.h"
#import "AddBabyInformationViewController.h"
#import "BookingOrderViewController.h"
#import "BodyCheckCheckResultListViewController.h"
@interface MembershipDetailsViewController ()<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate, UITextViewDelegate,UIImagePickerControllerDelegate,UIAlertViewDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UIActionSheetDelegate,MemberInformationViewControllerDelegate,TheEditingViewControllerDelegate,SelectTag_NewViewControllerDelegate,MemberExchangeGiftViewControllerDelegate,MemberCardTopUpViewControllerDelegate,UITextFieldDelegate,AddBabyInformationViewControllerDelegate,RCIMClientReceiveMessageDelegate>

{
    ReabamSingleton*commdity;
    MJRefreshHeaderView* _header;
    MJRefreshFooterView* _footer;
    NSMutableArray *array;
    NSMutableArray *arrayImage;
    NSString* tradeMoney;
    NSString* couponQty;
    NSString* actQty;
    NSString* integral;
    NSString* cardMoney;
    NSString* bookingQty;
    UIButton*name;
    UIImageView *imageView;
    UIView *headerView;
    UIButton* theArrowBtn;
    NSDictionary *DataLine;
    UIButton *TheMessageBtn;
    NSString* userStatus;
    UITableView*table;
    NSDictionary*Dict;
    TagView*tagV;
    UILabel*noteLebal;
    UILabel*tagLebal;
    UILabel*babyInformationLebal;
    UIView*supplementaryInformationView;
    UIView*myToolBar;
    UITextField*dueDateTextFied;
    NSMutableArray*selectTagNameArray;
    NSMutableArray*selectTagCodeArray;
    NSMutableArray*babyInformationArray;
    NSMutableArray*displayArray;
    NSMutableArray*funCodeArray;
    NSMutableArray*funNameArray;
}
@property(nonatomic,retain)UIDatePicker* da;
@end
@implementation MembershipDetailsViewController
@synthesize alt = alt;
-(void)BackAction:(UIButton *)sender{
    commdity.dataMemberDict=nil;
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    self.navigationController.delegate = nil;
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.view.backgroundColor=[UIColor whiteColor];
    [self setNavi];
}
-(void)xiangqing:(UIButton*)sender{
    MemberInformationViewController *detailViewController = [[MemberInformationViewController alloc] init];
    detailViewController.memberId=self.memberId;
    detailViewController.delegate=self;
    [self.navigationController pushViewController:detailViewController animated:YES];
}
-(void)memberSales:(UIButton*)sender{//会员销售
    CashierNewViewController *detailViewController = [[CashierNewViewController alloc] init];
    commdity.dataMemberDict=Dict;
    [Global setScanTitle:@"收银"];
    [Global setPlaceOrderPType:@"saleItem"];
    [Global setType:@"SCANCASHIER"];
    [self.navigationController pushViewController:detailViewController animated:YES];
}
-(void)update:(NSString *)Str{
    [self setNavi];
    [self update];
    [_delegate update:@""];
}
-(void)viewDidLoad{
    [super viewDidLoad];
    commdity=[[ReabamSingleton shared]init];
    selectTagNameArray=[[NSMutableArray alloc]init];
    selectTagCodeArray=[[NSMutableArray alloc]init];
    babyInformationArray=[[NSMutableArray alloc]init];
    funCodeArray=[[NSMutableArray alloc]init];
    displayArray=[[NSMutableArray alloc]init];
    funNameArray=[[NSMutableArray alloc]init];
    
    table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    
    table.separatorStyle=UITableViewCellSeparatorStyleNone;
    [self.view addSubview:table];
    [self update];
    UIButton*memberSales = [[UIButton alloc] initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth, 48)];
    [memberSales setTitle:@"会员销售" forState:UIControlStateNormal];
    [memberSales setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    memberSales.backgroundColor=luseColor;
    [memberSales addTarget:self action:@selector(memberSales:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:memberSales];
    
}
- (void)update
{
    [headerView removeFromSuperview];
    headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth,110+35)];
    table.tableHeaderView = headerView;
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:self.memberId forKey:@"memberId"];
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    [HttpRequest requestData:@"Business/Member/Detail" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"mmmmmm====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                tradeMoney=[severDataDict.dataDict objectForKey:@"tradeMoney"];
                couponQty=[severDataDict.dataDict objectForKey:@"couponQty"];
                actQty=[severDataDict.dataDict objectForKey:@"actQty"];
                integral=[severDataDict.dataDict objectForKey:@"integral"];
                cardMoney=[severDataDict.dataDict objectForKey:@"cardMoney"];
                bookingQty=[severDataDict.dataDict objectForKey:@"bookingQty"];
                Dict=severDataDict.dataDict;
                NSMutableArray* arrrs=[severDataDict.dataDict objectForKey:@"tags"];
                NSMutableArray* Codearrr=[[NSMutableArray alloc]init];
                NSMutableArray* Namearrr=[[NSMutableArray alloc]init];
                for (NSDictionary* dicc in arrrs )
                {
                    [Codearrr addObject:[dicc valueForKey:@"code"]];
                    [Namearrr addObject:[dicc valueForKey:@"content"]];
                }
                
                selectTagNameArray=[Namearrr copy];
                selectTagCodeArray=[Codearrr copy];
                [self heardView];
                [self footerView];
                table.delegate = self;
                table.dataSource = self;
                table.separatorStyle=UITableViewCellSeparatorStyleNone;
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:requestResultStr delegate:self cancelButtonTitle:@"确定返回" otherButtonTitles: nil];
                [alert show];
            }}
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
    }];
}
- (void)heardView
{
    arrayImage =[NSMutableArray arrayWithObjects:@"huiyuan-jiaoyimingxi",@"huiyuan-youhuiquan",@"jifenmingxi", nil];
    array=[NSMutableArray arrayWithObjects:@"累计消费",@"优惠券",@"会员积分", nil];
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSMutableArray* funConfigs = [user objectForKey:@"funConfigs"];
    [funNameArray removeAllObjects];
    if (funConfigs.count>0) {
        for (NSDictionary* dicc in funConfigs )
        {
            
            if ( [[NSString stringWithFormat:@"%@",[dicc valueForKey:@"display"] ]isEqualToString:@"1"]&&[[NSString stringWithFormat:@"%@",[dicc valueForKey:@"funCode"]]isEqualToString:@"member_valuecard"] ) {
                [array addObject:@"储值卡余额"];
                [arrayImage addObject:@"chuzhijilu"];
                
                
            }else if ([[NSString stringWithFormat:@"%@",[dicc valueForKey:@"display"] ]isEqualToString:@"1"]&&[[NSString stringWithFormat:@"%@",[dicc valueForKey:@"funCode"]]isEqualToString:@"member_booking"]){
                [array addObject:@"预约记录"];
                [arrayImage addObject:@"yuyuejilu"];
            }
        }
    }
    
    UIImageView* heardimage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 100)];
    heardimage.image=[UIImage imageNamed:@""];
    [headerView addSubview:heardimage];
    UIButton*Btn=[[UIButton alloc]init];
    Btn.backgroundColor=[UIColor clearColor];
    Btn.frame=CGRectMake(0, 0, ScreenWidth, 100);
    [Btn addTarget:self action:@selector(xiangqing:) forControlEvents:UIControlEventTouchUpInside];
    [headerView addSubview:Btn];
    imageView = [[UIImageView alloc]initWithFrame:CGRectMake(16.5, 14.5, 62.5, 62.5)];
    [imageView.layer setCornerRadius:4.0];
    [imageView.layer setBorderWidth:0.5];
    [imageView.layer setMasksToBounds:YES];
    CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0.93, 0.93, 0.93, 0.93 });
    [imageView.layer setBorderColor:colorref2];
    [imageView setImageWithURL:[NSURL URLWithString:[Dict objectForKey:@"headImage"]] placeholderImage:[UIImage imageNamed:@"touxiang"]];
    [headerView addSubview:imageView];
    UIImageView* heardimage1=[[UIImageView alloc]initWithFrame:CGRectMake(15, 17.5, 65, 65)];
    heardimage1.image=[UIImage imageNamed:@""];
    [headerView addSubview:heardimage1];
    UIView*huiseview=[[UIView alloc]initWithFrame:CGRectMake(0,100+35, ScreenWidth, 10)];
    huiseview.backgroundColor=zuiqianhuiColor;
    huiseview.layer.borderWidth = 0.40;
    huiseview.layer.borderColor = qianhuiColor.CGColor;
    [headerView addSubview:huiseview];
    NSString *s2 =[NSString stringWithFormat:@"%@",  [Dict objectForKey:@"userName"]];
    UIFont *font2 = [UIFont systemFontOfSize:16];
    CGSize size2 = CGSizeMake(ScreenWidth-60, 2000);
    CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
    
    theArrowBtn=[[UIButton alloc]init];
    theArrowBtn.backgroundColor=[UIColor clearColor];
    theArrowBtn.frame = CGRectMake(ScreenWidth-45,55/2, 30, 30);
    [theArrowBtn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    [theArrowBtn addTarget:self action:@selector(xiangqing:) forControlEvents:UIControlEventTouchUpInside];
    [headerView addSubview:theArrowBtn];
    name=[[UIButton alloc]initWithFrame:CGRectMake(imageView.right+15, 50/2, labelsize2.width, 16)];
    [name setTitle:s2 forState:UIControlStateNormal];
    name.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
    [name setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    name.titleLabel.font=[UIFont systemFontOfSize:16];
    [headerView addSubview:name];
    
    UIImageView*imageViews=[[UIImageView alloc]initWithFrame:CGRectMake(name.right, 48/2, 20, 20)];
    [headerView addSubview:imageViews];
    if (![[Dict objectForKey:@"sex"] isEqual:[NSNull null]]) {
        if ([[Dict objectForKey:@"sex"]isEqualToString:@"男"]) {
            imageViews.image=[UIImage imageNamed:@"nan"];
        }else{
            imageViews.image=[UIImage imageNamed:@"nv"];
        }
    }else{
        imageViews.image=[UIImage imageNamed:@"nv"];
        
    }
    
    UILabel*level=[[UILabel alloc]initWithFrame:CGRectMake(imageViews.right+15, 52/2, 30, 14)];
    level.font=[UIFont systemFontOfSize:14];
    level.text=@"等级";
    level.textColor=zhonghuiColor;
    [headerView addSubview:level];
    NSString *gradeNames =[NSString stringWithFormat:@"%@",  [Dict objectForKey:@"gradeName"]];
    UIFont *gradeNamefont2 = [UIFont systemFontOfSize:14];
    CGSize gradeNamesize2 = CGSizeMake(ScreenWidth-60, 2000);
    CGSize gradeNamelabelsize2 = [gradeNames sizeWithFont:gradeNamefont2 constrainedToSize:gradeNamesize2 lineBreakMode:NSLineBreakByCharWrapping];
    UILabel*grade1=[[UILabel alloc]initWithFrame:CGRectMake(level.right+2, 52/2, gradeNamelabelsize2.width, 14)];
    grade1.font= [UIFont systemFontOfSize:14];
    [grade1.layer setCornerRadius:1.5];
    [grade1.layer setBorderWidth:0];
    [grade1.layer setMasksToBounds:YES];
    grade1.textAlignment=NSTextAlignmentCenter;
    grade1.textColor=[UIColor whiteColor];
    [headerView addSubview:grade1];
    //    if ([[NSString stringWithFormat:@"%@",[Dict objectForKey:@"gradeName"]] isEqualToString:@"金"]) {
    grade1.text=[Dict objectForKey:@"gradeName"];
    grade1.backgroundColor=[UIColor colorWithRed:209/255.0 green:170/255.0 blue:56/255.0 alpha:1.0];
    
    UILabel*phone=[[UILabel alloc]initWithFrame:CGRectMake(imageView.right+15,name.bottom+10, ScreenWidth, 13)];
    phone.text=[Dict objectForKey:@"phone"];
    phone.textColor=shenhuiColor;
    phone.font=[UIFont systemFontOfSize:13];
    [headerView addSubview:phone];
    
    UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2, 107.5-10, 0.5, 30)];
    line.backgroundColor=qianhuiColor;
    [headerView addSubview:line];
    UIImageView *_hengxian = [[UIImageView alloc]initWithFrame:CGRectMake(10,90, ScreenWidth-20, 0.5)];
    _hengxian.image=[UIImage imageNamed:@"hengxian"];
    [headerView addSubview:_hengxian];
    
    NSArray *buttonContent = @[@"消息",@"电话"];
    NSArray *buttonContentimage = @[@"huiyuanxiaoxi",@"dianhua"];
    for (int i = 0;  i<2; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(ScreenWidth/2*i+10, 90, ScreenWidth/2, 45);
        [button setTitle:[buttonContent objectAtIndex:i] forState:UIControlStateNormal];
        button.titleLabel.font=[UIFont systemFontOfSize:15];
        [button setTitleColor:zhonghuiColor forState:UIControlStateNormal];
        button.contentHorizontalAlignment=UIControlContentHorizontalAlignmentCenter;
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        button.tag = i+1;
        [headerView addSubview:button];
        UIButton *shanghubutton = [UIButton buttonWithType:UIButtonTypeCustom];
        shanghubutton.frame = CGRectMake(ScreenWidth/2/2-42.5+ScreenWidth/2*i, 98, 30, 30);
        [shanghubutton setImage:[UIImage imageNamed:[buttonContentimage objectAtIndex:i]] forState:UIControlStateNormal];
        [shanghubutton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        shanghubutton.tag = i+1;
        [headerView addSubview:shanghubutton];
    }
    [table reloadData];
}

- (void)footerView
{
    UIView * tableFooterViews=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 250+100)];
    UIView*huiseview1=[[UIView alloc]initWithFrame:CGRectMake(0,0, ScreenWidth, 10)];
    huiseview1.backgroundColor=zuiqianhuiColor;
    huiseview1.layer.borderWidth = 0.3;
    huiseview1.layer.borderColor = qianhuiColor.CGColor;
    [tableFooterViews addSubview:huiseview1];
    
    UIButton*tagLabel=[[UIButton alloc]initWithFrame:CGRectMake(20, 10, ScreenWidth, 50)];
    [tagLabel setTitle:@"标签" forState:UIControlStateNormal];
    tagLabel.titleLabel.font= [UIFont systemFontOfSize:15];
    tagLabel.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
    [tagLabel addTarget:self action:@selector(SelectTag:) forControlEvents:UIControlEventTouchUpInside];
    [tagLabel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [tableFooterViews addSubview:tagLabel];
    UILabel*lineLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, tagLabel.bottom, ScreenWidth-20, 0.40)];
    lineLabel.backgroundColor=qianhuiColor;
    [tableFooterViews addSubview:lineLabel];
    UIButton*btn=[[UIButton alloc]init];
    btn.frame=CGRectMake(ScreenWidth-45, tagLabel.bottom-50+9, 33, 33);
    [btn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(SelectTag:) forControlEvents:UIControlEventTouchUpInside];
    [tableFooterViews addSubview:btn];
    tagLebal=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, 10,  150, 50)];
    tagLebal.font= [UIFont systemFontOfSize:14];
    tagLebal.textColor=hongseColor;
    tagLebal.textAlignment=NSTextAlignmentRight;
    tagLebal.text=[NSString stringWithFormat:@"已选择%ld个",  selectTagNameArray.count];
    [tableFooterViews addSubview:tagLebal];
    
    if (selectTagNameArray.count>0) {
        UIImageView *_hengxian = [[UIImageView alloc]initWithFrame:CGRectMake(10,tagLabel.bottom, ScreenWidth-20, 0.5)];
        _hengxian.image=[UIImage imageNamed:@"hengxian"];
        [tableFooterViews addSubview:_hengxian];
        for (int i = 0,j = 0; i < selectTagNameArray.count; i++) {
            if (i % 4 == 0) {
                j++;
            }
            tagV = [[TagView alloc]initWithFrame:CGRectMake(12.5+(ScreenWidth/4-5)*(i%4), (31*j)+_hengxian.bottom-20, ScreenWidth/4-15, 25)];
            tagV.buttonView.titleLabel.textAlignment=NSTextAlignmentCenter;
            tagV.buttonView.titleLabel.font=[UIFont systemFontOfSize:contenfot];
            [tagV.buttonView setTitle: [selectTagNameArray objectAtIndex:i]  forState:UIControlStateNormal];
            CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
            CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){209/255.0,170/255.0, 56/255.0, 1.0   });
            tagV.buttonView.backgroundColor=[UIColor colorWithRed:255/255.0 green:250/255.0 blue:234/255.0 alpha:1];
            [tagV.buttonView.layer setBorderColor:colorref2];//边框颜色
            [tagV.buttonView setTitleColor:[UIColor colorWithRed:207/255.0 green:170/255.0 blue:68/255.0 alpha:1] forState:0];
            [tableFooterViews addSubview:tagV];
            
        }
        lineLabel.frame=CGRectMake(10, tagV.bottom+10, ScreenWidth-20, 0.40);
    }else{
        tagLebal.text=@"未选择";
    }
    
    UIButton*note=[[UIButton alloc]initWithFrame:CGRectMake(20, lineLabel.bottom, ScreenWidth, 50)];
    [note setTitle:@"备注" forState:UIControlStateNormal];
    note.titleLabel.font= [UIFont systemFontOfSize:15];
    note.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
    [note addTarget:self action:@selector(note:) forControlEvents:UIControlEventTouchUpInside];
    [note setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [tableFooterViews addSubview:note];
    
    noteLebal=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, lineLabel.bottom, 150, 50)];
    noteLebal.font= [UIFont systemFontOfSize:contenfot];
    noteLebal.textColor=shenhuiColor;
    noteLebal.textAlignment=NSTextAlignmentRight;
    noteLebal.text=[NSString stringWithFormat:@"%@",  [Dict objectForKey:@"remark"]];
    [tableFooterViews addSubview:noteLebal];
    UIButton*renzhenButton=[[UIButton alloc]init];
    renzhenButton.frame=CGRectMake(ScreenWidth-45, note.bottom-50+9, 33, 33);
    [renzhenButton setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    [renzhenButton addTarget:self action:@selector(note:) forControlEvents:UIControlEventTouchUpInside];
    [tableFooterViews addSubview:renzhenButton];
    
    
    
    //补充信息
    supplementaryInformationView=[[UIView alloc]initWithFrame:CGRectMake(0, note.bottom, ScreenWidth, 100)];
    supplementaryInformationView.backgroundColor=[UIColor whiteColor];
    [tableFooterViews addSubview:supplementaryInformationView];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSMutableArray* funConfigs = [user objectForKey:@"funConfigs"];
    [funNameArray removeAllObjects];
    if (funConfigs.count>0) {
        for (NSDictionary* dicc in funConfigs )
        {
            if ( [[NSString stringWithFormat:@"%@",[dicc valueForKey:@"display"] ]isEqualToString:@"1"]&&[[NSString stringWithFormat:@"%@",[dicc valueForKey:@"funCode"]]isEqualToString:@"member_moreinfo_baby"] ) {
                [funNameArray addObject:@"宝宝信息"];
            }else if ([[NSString stringWithFormat:@"%@",[dicc valueForKey:@"display"] ]isEqualToString:@"1"]&&[[NSString stringWithFormat:@"%@",[dicc valueForKey:@"funCode"]]isEqualToString:@"member_moreinfo_bodycheck"]){
                [funNameArray addObject:@"会员检测"];
            }else if ([[NSString stringWithFormat:@"%@",[dicc valueForKey:@"display"] ]isEqualToString:@"1"]&&[[NSString stringWithFormat:@"%@",[dicc valueForKey:@"funCode"]]isEqualToString:@"member_moreinfo_yuchanqi"]){
                [funNameArray addObject:@"预产期"];
            }
            
        }
        
        
        supplementaryInformationView .frame=CGRectMake(0, note.bottom, ScreenWidth, funNameArray.count*50+60);
        UIView*huiseview=[[UIView alloc]initWithFrame:CGRectMake(0,0, ScreenWidth, 10)];
        huiseview.backgroundColor=zuiqianhuiColor;
        huiseview.layer.borderWidth = 0.40;
        huiseview.layer.borderColor = qianhuiColor.CGColor;
        [supplementaryInformationView addSubview:huiseview];
        UIButton *buchongxinxi = [UIButton buttonWithType:UIButtonTypeCustom];
        buchongxinxi.frame = CGRectMake(0, 25, 18, 18);
        [buchongxinxi setBackgroundImage:[UIImage imageNamed:@"buchongxinxi"] forState:UIControlStateNormal];
        [supplementaryInformationView addSubview:buchongxinxi];
        
        UILabel*bu=[[UILabel alloc]initWithFrame:CGRectMake(20, 10, 150, 50)];
        bu.text=@"补充信息";
        bu.font= [UIFont systemFontOfSize:16];
        [bu setTextColor:luseColor];
        [supplementaryInformationView addSubview:bu];
        
        for (int i = 0; i<funNameArray.count; i++) {
            UIButton*funNameBtn=[[UIButton alloc]initWithFrame:CGRectMake(20, 60+50*i, ScreenWidth-15, 50)];
            [funNameBtn setTitle:[NSString stringWithFormat:@"%@",funNameArray[i]] forState:UIControlStateNormal];
            [funNameBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
            [funNameBtn addTarget:self action:@selector(funNameBtn:) forControlEvents:UIControlEventTouchUpInside];
            funNameBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
            funNameBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
            [supplementaryInformationView addSubview:funNameBtn];
            
            UIButton*btn=[[UIButton alloc]init];
            btn.frame=CGRectMake(ScreenWidth-45, 60+50*i+8, 33, 33);
            [btn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
            [supplementaryInformationView addSubview:btn];
            
            UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(10, 110+50*(i), ScreenWidth-20, 0.40)];
            line.backgroundColor=qianhuiColor;
            [supplementaryInformationView addSubview:line];
            
            if ([[NSString stringWithFormat:@"%@",funNameArray[i]]isEqualToString:@"宝宝信息"]) {
                babyInformationArray=[Dict objectForKey:@"babys"];
                if (babyInformationArray.count>0) {
                    for (int j = 0; j < babyInformationArray.count; j++) {
                        if (j<3) {
                            babyInformationLebal=[[UILabel alloc]initWithFrame:CGRectMake((ScreenWidth-(j+1)*90)-30, 60+50*i, 90, 50)];
                            babyInformationLebal.font= [UIFont systemFontOfSize:13];
                            babyInformationLebal.textColor=shenhuiColor;
                            babyInformationLebal.textAlignment=NSTextAlignmentCenter;
                            if ([[NSString stringWithFormat:@"%@",  [babyInformationArray[j]objectForKey:@"name"]]length]>0) {
                                babyInformationLebal.text=[NSString stringWithFormat:@"%@%@",  [babyInformationArray[j]objectForKey:@"name"], [self getUTCFormateDate: [babyInformationArray[j]objectForKey:@"birthDate"]]];
                            }
                            [supplementaryInformationView addSubview:babyInformationLebal];
                        }
                        
                    }
                }
                
            }else if ([[NSString stringWithFormat:@"%@",funNameArray[i]]isEqualToString:@"预产期"]){
                
                _da = [[UIDatePicker alloc] init];
                [_da addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
                _da.datePickerMode = UIDatePickerModeDate;
                _da.backgroundColor=[UIColor whiteColor];
                
                dueDateTextFied=[[UITextField alloc]initWithFrame:CGRectMake(ScreenWidth-165,  60+50*i, 150,  50)];
                dueDateTextFied.borderStyle = UITextBorderStyleNone;
                dueDateTextFied.font = [UIFont systemFontOfSize: contenfot];
                dueDateTextFied.textColor=shenhuiColor;
                dueDateTextFied.tag=5;
                dueDateTextFied.placeholder = @" 预产时间"; //默认显示的字
                if ([[NSString stringWithFormat:@"%@",  [Dict objectForKey:@"dueDate"]]length]>3) {
                    NSRange range={0,10};
                    NSString* string =[[Dict objectForKey:@"dueDate"] substringWithRange:range];
                    dueDateTextFied.text= string;
                    _da.date =[self dateFromString:dueDateTextFied.text ];
                }else{
                    
                }
                
                dueDateTextFied.textAlignment=NSTextAlignmentCenter;
                dueDateTextFied.delegate = self;
                [supplementaryInformationView addSubview:dueDateTextFied];
                dueDateTextFied.inputView = _da;
                dueDateTextFied.inputAccessoryView= myToolBar;
            }else if ([[NSString stringWithFormat:@"%@",funNameArray[i]]isEqualToString:@"会员检测"]){
                UILabel* bodyCheckQty=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, 60+50*i, 150, 50)];
                bodyCheckQty.font= [UIFont systemFontOfSize:13];
                bodyCheckQty.textColor=shenhuiColor;
                bodyCheckQty.textAlignment=NSTextAlignmentRight;
                bodyCheckQty.text=[NSString stringWithFormat:@"%@",  [Dict objectForKey:@"bodyCheckQty"]];
                [supplementaryInformationView addSubview:bodyCheckQty];
                
                
            }
            
        }
        
        
        tableFooterViews.frame=CGRectMake(0, 0, ScreenWidth, supplementaryInformationView.bottom+200);
        table.tableFooterView = tableFooterViews;
        
        
    }else{
        UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, noteLebal.bottom, ScreenWidth, 0.40)];
        line.backgroundColor=qianhuiColor;
        [tableFooterViews addSubview:line];
        [supplementaryInformationView removeFromSuperview];
        tableFooterViews.frame=CGRectMake(0, 0, ScreenWidth, note.bottom+200);
        table.tableFooterView = tableFooterViews;
        
        
    }
    
}

-(void)funNameBtn:(UIButton*)sender{
    
    
    
    
    [dueDateTextFied resignFirstResponder];
    if ([sender.titleLabel.text isEqualToString:@"会员检测"]) {
        
        BodyCheckCheckResultListViewController *detailViewController = [[BodyCheckCheckResultListViewController alloc] init];
        detailViewController. memberId=self.memberId;
        [self.navigationController pushViewController:detailViewController animated:YES];
        
        
    }else if ([sender.titleLabel.text isEqualToString:@"宝宝信息"]){
        
        AddBabyInformationViewController *detailViewController = [[AddBabyInformationViewController alloc] init];
        detailViewController.babys=[Dict objectForKey:@"babys"];
        detailViewController.delegate=self;
        [self.navigationController pushViewController:detailViewController animated:YES];
        
        
    }else if ([sender.titleLabel.text isEqualToString:@"预产期"]){
        
    }
    
    
}

-(void)dateChanged1:(UIButton*)sender{
    UIDatePicker* picker = (UIDatePicker*)sender;
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    if ([dueDateTextFied isFirstResponder])
    {
        dueDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
        
    }else{
        
        dueDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
    }
}
-(void)dateChanged:(UIButton*)sender{
    UIDatePicker* picker = (UIDatePicker*)sender;
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    if ([dueDateTextFied isFirstResponder])
    {
        dueDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
        
    }else{
        
        dueDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
    }
}
-(void)babyInformation:(UIButton*)sender{
    [dueDateTextFied resignFirstResponder];
    AddBabyInformationViewController *detailViewController = [[AddBabyInformationViewController alloc] init];
    detailViewController.babys=[Dict objectForKey:@"babys"];
    detailViewController.delegate=self;
    [self.navigationController pushViewController:detailViewController animated:YES];
}
-(void)SelectTag:(UIButton*)sender{
    SelectTag_NewViewController *detailViewController = [[SelectTag_NewViewController alloc] init];
    detailViewController.optionNameString=@"MemberTag";
    detailViewController.selectedTagCodeArray=selectTagCodeArray;
    detailViewController.selectedTagNameArray=selectTagNameArray;
    detailViewController.delegate=self;
    [self.navigationController pushViewController:detailViewController animated:YES];
}

-(void)note:(UIButton*)sender{
    TheEditingViewController * Login=[[TheEditingViewController alloc]init];
    Login.type=@"memo";
    Login.userNameStr=[NSString stringWithFormat:@"%@",[Dict objectForKey:@"userName"]];
    Login.sexStr=[NSString stringWithFormat:@"%@",[Dict objectForKey:@"sex"]];
    Login.memoStr=[NSString stringWithFormat:@"%@",[Dict objectForKey:@"remark"]];
    Login.titleName=@"备注";
    Login.delegate = self;
    [self.navigationController pushViewController:Login animated:YES];
}

-(void)secondViewController:(AddBabyInformationViewController *)secondViewController babys:(NSMutableArray *)babyss{
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:self.memberId forKey:@"id"];
    [params setValue:babyss forKey:@"babys"];
    [HttpRequest requestData:@"Business/Member/Edit" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                [self update:@""];
            }else{
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }}
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }}];
    
    
}
-(void)secondViewController:(SelectTag_NewViewController *)secondViewController selectTagCodeArray:(NSMutableArray *)selectTagCodeArrays selectTagNameArray:(NSMutableArray *)selectTagNameArrays{
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:self.memberId forKey:@"id"];
    NSMutableArray *mDocumentLine=[NSMutableArray array];
    for (int i=0; i<selectTagCodeArrays.count; i++) {
        
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        NSString *codeStr = [selectTagCodeArrays objectAtIndex:i];
        [dic setValue:codeStr forKey:@"code"];
        [mDocumentLine addObject:dic];
    }
    [params setValue:mDocumentLine  forKey:@"tags"];
    [HttpRequest requestData:@"Business/Member/Edit" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        
        if (isSuccess) {
            NSLog(@"%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                [self update:@""];
            }else{
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }}
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }}];
}
- (void)secondViewController:(TheEditingViewController *)secondViewController updateUserNameText:(NSString *)userNameStr updateSexStr:(NSString *)sexStr updateMemoStr:(NSString *)memoStr
{
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:self.memberId forKey:@"id"];
    [params setValue:memoStr forKey:@"remark"];
    [HttpRequest requestData:@"Business/Member/Edit" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                [self update:@""];
            }else{
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }}
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }}];
}

-(void)RequestRongYunToken
{
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:@"member" forKey:@"userType"];
    [param setValue:self.memberId forKey:@"memberId"];
    [param setValue:[NSString stringWithFormat:@"%@",[Dict objectForKey:@"headImage"]] forKey:@"headImage"];
    //    NSLog(@"-----------%@",param);
    [HttpRequest requestData:@"Chat/RegChat" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        //NSLog(@"mm-----------%@",severDataDict.dataDict);
        if (isSuccess) {
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                
                
                //             [[RCIMClient sharedRCIMClient] setReceiveMessageDelegate:self object:[severDataDict.dataDict objectForKey:@"chatInfo"]];
                ConversationViewController *conversationVC = [[ConversationViewController alloc]init];
                conversationVC.conversationType = ConversationType_PRIVATE;
                //              conversationVC.conv =[[severDataDict.dataDict objectForKey:@"chatInfo"] objectForKey:@"chatUserLogoUrl"];
                conversationVC.targetId =[[severDataDict.dataDict objectForKey:@"chatInfo"] objectForKey:@"chatUserID"];
                conversationVC.title =[[severDataDict.dataDict objectForKey:@"chatInfo"] objectForKey:@"chatUserName"];
                [self.navigationController pushViewController:conversationVC animated:YES];
            }
            else{
                
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:[severDataDict.dataDict objectForKey:@"ResultString"]  view:self.view];
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    TheLoginViewController *detailViewController = [[TheLoginViewController alloc] init];
                    [self.navigationController pushViewController:detailViewController animated:YES];
                }
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
        
    }];
    
}

- (void)buttonAction:(UIButton *)button{
    switch (button.tag)
    {
        case 1:
            
            if (button.tag==1) {
                
                NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
                
                userStatus = [user objectForKey:@"userStatus"];
                
                if ([userStatus isEqualToString:@"Y"]) {
                    
                    [self RequestRongYunToken];
                    
                }
            }
            break;
            
        case 2:
            
            if (button.tag==2) {
                
                [ACETelPrompt callPhoneNumber: [Dict objectForKey:@"phone"]
                                         call:^(NSTimeInterval duration) {
                                             NSLog(@"User made a call of %.1f seconds", duration);
                                             
                                         } cancel:^{
                                             NSLog(@"User cancelled the call");
                                         }];
            }
            break;
        default:
            break;
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    MemberInformationCell* cell = (MemberInformationCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell = [[MemberInformationCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] ;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayImage objectAtIndex:indexPath.row]]];
    UIButton*jiantou1 = [[UIButton alloc]init];
    jiantou1.frame = CGRectMake(ScreenWidth-45,8.5, 33, 33);
    cell.accessoryView=jiantou1;
    
    UIButton*jiantou = [[UIButton alloc]init];
    jiantou.frame = CGRectMake(ScreenWidth-45,8.5, 33, 33);
    [jiantou setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    jiantou.userInteractionEnabled=NO;
    [cell.contentView addSubview:jiantou];
    
    cell.textLabel.text = [array objectAtIndex:indexPath.row];
    cell.textLabel.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
    cell.textLabel.font=[UIFont systemFontOfSize:15];
    cell.detailTextLabel.font=[UIFont systemFontOfSize:14];
    if ([[array objectAtIndex:indexPath.row] isEqualToString:@"累计消费"]) {
        NSString*GoldPrice1=[NSString stringWithFormat:@"%@",tradeMoney];
        NSNumberFormatter *numberFormatter1 = [[NSNumberFormatter alloc] init];
        [numberFormatter1 setPositiveFormat:@"###,##0.00;"];
        NSString *formattedNumberString1 = [numberFormatter1 stringFromNumber:[NSNumber numberWithDouble:GoldPrice1.floatValue]];
        cell.detailTextLabel.text=[NSString stringWithFormat:@"¥ %@",formattedNumberString1];
    }
    if ([[array objectAtIndex:indexPath.row] isEqualToString:@"优惠券"]) {
        cell.detailTextLabel.text=[NSString stringWithFormat:@"%@",couponQty];
    }
    if ([[array objectAtIndex:indexPath.row] isEqualToString:@"会员积分"]) {
        NSString*GoldPrice1=[NSString stringWithFormat:@"%@",integral];
        NSNumberFormatter *numberFormatter1 = [[NSNumberFormatter alloc] init];
        [numberFormatter1 setPositiveFormat:@"###,##0;"];
        NSString *formattedNumberString1 = [numberFormatter1 stringFromNumber:[NSNumber numberWithDouble:GoldPrice1.floatValue]];
        cell.detailTextLabel.text=[NSString stringWithFormat:@"%@",formattedNumberString1];
    }
    if ([[array objectAtIndex:indexPath.row]isEqualToString:@"储值卡余额"]) {
        NSString*GoldPrice1=[NSString stringWithFormat:@"%@",cardMoney];
        NSNumberFormatter *numberFormatter1 = [[NSNumberFormatter alloc] init];
        [numberFormatter1 setPositiveFormat:@"###,##0.00;"];
        NSString *formattedNumberString1 = [numberFormatter1 stringFromNumber:[NSNumber numberWithDouble:GoldPrice1.floatValue]];
        cell.detailTextLabel.text=[NSString stringWithFormat:@"¥ %@",formattedNumberString1];
    }
    if ([[array objectAtIndex:indexPath.row]isEqualToString:@"预约记录"]) {
        cell.detailTextLabel.text=[NSString stringWithFormat:@"%@",bookingQty];
    }
    if (array.count !=indexPath.row+1) {
        UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(60, 50-0.40, ScreenWidth-75, 0.40)];
        lineLabel1.backgroundColor=qianhuiColor;
        [cell.contentView addSubview:lineLabel1];
        
    }
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    MemberInformationCell *cell =(MemberInformationCell *)[tableView cellForRowAtIndexPath:indexPath];
    if ([cell.textLabel.text isEqualToString:@"累计消费"]) {
        TradesViewController * Login=[[TradesViewController alloc]init];
        Login.memberId=self.memberId;
        [self.navigationController pushViewController:Login animated:YES];}
    if ([cell.textLabel.text isEqualToString:@"优惠券"]) {
        MCouponBViewController * Login=[[MCouponBViewController alloc]init];
        Login.memberId=self.memberId;
        Login.titleName=@"优惠券";
        Login.phone=[Dict objectForKey:@"phone"];
        [self.navigationController pushViewController:Login animated:YES];}
    if ([cell.textLabel.text isEqualToString:@"会员积分"]) {
        MemberExchangeGiftViewController * Login=[[MemberExchangeGiftViewController alloc]init];
        Login.memberId=self.memberId;
        Login.delegate=self;
        Login.price=[NSString stringWithFormat:@"%@",integral];
        [self.navigationController pushViewController:Login animated:YES];
    }
    if ([cell.textLabel.text isEqualToString:@"储值卡余额"]) {
        
        MemberCardTopUpViewController * Login=[[MemberCardTopUpViewController alloc]init];
        Login.memberId=self.memberId;
        Login.delegate=self;
        Login.price= [NSString stringWithFormat:@"%@",cardMoney];
        [self.navigationController pushViewController:Login animated:YES];
    }
    if ([cell.textLabel.text isEqualToString:@"预约记录"]) {
        
        BookingOrderViewController * Login=[[BookingOrderViewController alloc]init];
        Login.memberId=self.memberId;
        [self.navigationController pushViewController:Login animated:YES];
    }
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  50;
}

- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}
- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
-(void)setNavi{
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
    self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    
    self.title = @"会员详情";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
    myToolBar.backgroundColor=jianpancolor;
    UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
    [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:tubtnDone];
    UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
    [btnDone111 setTitle:@"确定" forState:UIControlStateNormal];
    [btnDone111 setTitleColor:jianpancolor1 forState:UIControlStateNormal];
    btnDone111 .titleLabel .font=[UIFont systemFontOfSize:keyboardFot];
    [btnDone111 addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:btnDone111];
    myToolBar.alpha=alp;
    UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
    [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:dabtn];
    
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    table.frame =CGRectMake(0, -150, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
}
-(void)OnTapDone{
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:self.memberId forKey:@"id"];
 
    
    if (dueDateTextFied.text.length<1) {
        NSDateFormatter* df = [[NSDateFormatter alloc] init];
        [df setDateFormat:@"yyyy-MM-dd"];
        dueDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:[NSDate date]]];
    }

    [params setValue:dueDateTextFied.text forKey:@"dueDate"];
  
    
    [HttpRequest requestData:@"Business/Member/Edit" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                
                
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"修改成功" view:self.view];
                [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
                table.frame =CGRectMake(0, 0, ScreenWidth, ScreenHeight);
                [UIView commitAnimations];
                [dueDateTextFied resignFirstResponder];
            }else{
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }}
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }}];
    
    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0) {
        [self.navigationController popViewControllerAnimated:YES];
    }
}
-(NSString *)getUTCFormateDate:(NSString *)newsDate
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSDate *newsDateFormatted = [dateFormatter dateFromString:newsDate];
    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
    [dateFormatter setTimeZone:timeZone];
    NSDate* current_date = [[NSDate alloc] init];
    NSTimeInterval time=[current_date timeIntervalSinceDate:newsDateFormatted];//间隔的秒数
    int month=((int)time)/(3600*24*30);
    int days=((int)time)/(3600*24);
    NSString *dateMonth;
    if(month!=0){
        dateMonth = [NSString stringWithFormat:@"%d岁",month];
    }else if(days!=0){
        //31天以下还是显示0月
        //        dateMonth = [NSString stringWithFormat:@"%d%@",days,@"天"];
        dateMonth = [NSString stringWithFormat:@"%@%@",@"0",@"个月"];
    }
    
    if (month/12>=1) {
        int dateYear=month/12;
        int dateYear1=month%12;
        dateMonth = [NSString stringWithFormat:@"%d岁%d个月",dateYear,dateYear1];
        
    }else{
        int dateYear1=month%12;
        dateMonth = [NSString stringWithFormat:@"%d个月",dateYear1];
    }
    
    return dateMonth;
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
    
    
    if (textField.tag==5) {
        if (textField.text.length<1) {
            NSDateFormatter* df = [[NSDateFormatter alloc] init];
            [df setDateFormat:@"yyyy-MM-dd"];
            dueDateTextFied.text = [NSString stringWithFormat:@"%@", [df stringFromDate:[NSDate date]]];
        }
    }
}
- (NSDate *)dateFromString:(NSString *)dateString{
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    [dateFormatter setDateFormat: @"yyyy-MM-dd"];
    
    NSDate *destDate= [dateFormatter dateFromString:dateString];
    
    return destDate;
    
}
@end
